<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
</head>
<body>
    <h2>个人信息管理</h2>
    <div style="margin:10px 0;"></div>
    <table id="employee"></table>
    <div id="dlg" class="easyui-panel" style="width:900px;height:400px;padding:10px 20px">
        <form id="fm" method="post" novalidate>
            <div class="fitem">
                <label>用户名:</label>
                <input name="name" readonly="readonly" required="true" style="border:0">
            </div>
            <div class="fitem">
                <label>姓名:</label>
                <input name="display" class="easyui-validatebox"required="true">
            </div>
            <div class="fitem">
                <label>密码:</label>
                <input name="password" type="password">
            </div>
            <div class="fitem">
                <label>邮箱:</label>
                <input name="email" required="true" class="easyui-validatebox" validType="email">
            </div>
            <div class="fitem">
                <label>电话:</label>
                <input name="cell" class="easyui-numberbox">
            </div>
            <div class="fitem">
                <label>性别:</label>
                <select id="sex" class="easyui-combobox" name="sex">
    				<option value="MAN">男</option>
    				<option value="WOMAN">女</option>
				</select>
            </div>
            <div class="fitem">
                <label>状态:</label>
                <span id="status"></span>
            </div>
            <div class="fitem">
                <label>角色:</label>
                <span id="roles"></span>
            </div>
			<div class="fitem">
                <label>毕业院校:</label>
                <input name="college">
            </div>
            <div class="fitem">
                <label>学历:</label>
                <input name="education">
            </div>
            <div class="fitem">
                <label>年龄:</label>
                <input name="age" class="easyui-numberbox">
            </div>
            <div class="fitem">
                <label>薪水:</label>
                <span id="salary"></span>
            </div>
        </form>
      	<div id="dlg-buttons">
        	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="personalJs.update()">更新</a>
    	</div>
    </div>
    <script type="text/javascript">
(function(personalJs, $, undefined ) { 
	personalJs.init = function(){
		
		loadData(1,"dispatch/manage/personal/query");
	}
	
	function loadData(page,url){
		$.ajax({
            type: "post",
            url: url,
            dataType:"json",
            success: function (result) {
            	var res = result.result;
                if(res == "SUCCESS")
                {
                	var payload = jQuery.parseJSON(result.payload.value);
                	 $('#fm').form('load', payload);
                	 var roleText = '';
                	 for(var i=0;i<payload.roles.length;i++){
                		 roleText +=payload.roles[i].name+" ";
                	 }
                	 $('#roles').html(roleText);
                	 $('#salary').html(payload.salary);
                	 $('#status').html(payload.status);
                }else
                {
                	$.messager.alert("Error",result.result);
                }
                
            }
            
        });
	}
    personalJs.update = function(){
        $('#fm').form('submit',{
            url: "dispatch/manage/personal/edit",
            onSubmit: function(){
                return $(this).form('validate');
            },
            success: function(result){
                var result = eval('('+result+')');
                if (result.result == "SUCCESS"){
                    $.messager.show({
                        title: 'SUCCESS',
                        msg: result.payload.value
                    });
                } else {
                	$.messager.alert("Error",result.payload);
                }
            }
        });
    }
}( window.personalJs = window.personalJs || {}, jQuery ));

$(function(){
	personalJs.init();
});  
    	

    </script>
    <style type="text/css">
        #fm{
            margin:0;
            padding:10px 30px;
        }
        .ftitle{
            font-size:14px;
            font-weight:bold;
            padding:5px 0;
            margin-bottom:10px;
            border-bottom:1px solid #ccc;
        }
        .fitem{
            margin-bottom:5px;
        }
        .fitem label{
            display:inline-block;
            width:80px;
        }
    </style>
</body>
</html>